package com.top145;

import java.util.Arrays;
import java.util.Comparator;

public class Solution179 {
    public String largestNumber(int[] nums) {
        String[] numStr = new String[nums.length];
        for (int i = 0; i < nums.length; i++) {
            numStr[i] = "" + nums[i];
        }
        Arrays.sort(numStr, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return (o2 + o1).compareTo(o1 + o2);
            }
        });
        if (numStr[0].equals("0")) return "0";
        StringBuffer sb = new StringBuffer();
        for (String x : numStr) {
            sb.append(x);
        }
        return sb.toString();
    }
}
